<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function duplicates(arr) {
        var newarr = []
        arr.forEach((item) => {
          if (arr.indexOf(item) !== arr.lastIndexOf(item) && newarr.indexOf(item) == -1) {
            newarr.push(item)
          }
        })
        return newarr
      }
      console.log(duplicates([1, 2, 4, 4, 3, 3, 1, 5, 3]))
    </script>
  </body>
</html>
